--
-- Author: xuzhihui
-- Date: 2016-03-15 09:00:00
--
-- 模块基类
local ModuleBase = class("ModuleBase", me.ObjectBase)

function ModuleBase:ctor()
	ModuleBase.super.ctor(self)
	self._init = false
	self._initLate = false
	self._onInitCompleted = nil
end

function ModuleBase:Init(onCompleted)
	if self._init then
		return
	end

	self._init = true
	self._onInitCompleted = onCompleted
	self:DoInit()
end

function ModuleBase:LateInit(onCompleted)
	if self._initLate then
		return
	end

	self._initLate = true
	self._onInitCompleted = onCompleted
	self:DoLateInit()
end

-- 清除缓存
function ModuleBase:Clear(isLogout)
	
end

-- 清理
function ModuleBase:Dispose()
	ModuleBase.super.Dispose(self)
end

-- 更新
function ModuleBase:Update(dt)

end

-- 固定间隔更新
function ModuleBase:FixedUpdate(dt)
	
end

-- 初始化,子类重写
function ModuleBase:DoInit()
	self:OnInitCompleted()
end

function ModuleBase:DoLateInit()
	self:OnInitCompleted()
end

function ModuleBase:OnInitCompleted()
	if self._onInitCompleted then
		self._onInitCompleted(self)
	end
end

return ModuleBase